package com.mingdao.lhy.controller;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttribute;

import com.mingdao.lhy.biz.WishFillingBiz;
import com.mingdao.lhy.mapper.signup.SignUpStudentMapper2;
import com.mingdao.lhy.mapper.wish.MiddleSchoolMapper;
import com.mingdao.lhy.mapper.wish.PhotoMapper;
import com.mingdao.lhy.mapper.wish.XueJiMapper;
import com.mingdao.lhy.mapper.wish.ZkwMapper;
import com.mingdao.lhy.pojo.ResponseVo;
import com.mingdao.lhy.pojo.SignUpStudent;
import com.mingdao.lhy.pojo.Zkw;
import com.mingdao.lhy.pojo.page.ArtSpecialtySignUp;
import com.mingdao.lhy.pojo.page.ArtSpecialtySignUpCity;
import com.mingdao.lhy.pojo.page.ChangePassword;
import com.mingdao.lhy.service.CityService;
import com.mingdao.lhy.service.WishFillingService;

@Controller
@RequestMapping("/jkz")
public class WishJkzController {

	private static Logger log = LoggerFactory.getLogger(WishJkzController.class);

	@Value("${xsshkssj}")
	private String xsshkssj;

	@Value("${xsshjssj}")
	private String xsshjssj;

	@Autowired
	private WishFillingBiz wishFillingBiz;

	@Autowired
	private ZkwMapper zkwMapper;

	@Autowired
	private PhotoMapper photoMapper;

	@Autowired
	private XueJiMapper xueJiMapper;

	@Autowired
	private MiddleSchoolMapper juniorMapper;

	@Autowired
	private CityService cityService;

	@Autowired
	private WishFillingService wishFillingService;

	@Autowired
	private SignUpStudentMapper2 signUpStudentMapper2;

	@RequestMapping("")
	public String index() {
		return "loginJkz";
	}

	/**
	 * 县市招办登录验证页面
	 * 
	 * @return
	 */
	@RequestMapping(value = "/check", method = RequestMethod.POST)
	public String check(@ModelAttribute("zkw") Zkw zkw, Model model) {

		HttpSession session = wishFillingBiz.getSession();

		log.debug("进入【县市招办登录验证页面】");
		if (null == zkw || null == zkw.getUserid() || null == zkw.getPassword()) {
			log.error("没有收到有效的请求数据");
			model.addAttribute("msg", "没有收到有效的请求数据");
			return "loginJkz";
		}

		/**
		 * 如果登录的用户ID不为空，并且不等于"ls710001"和"ls710002"
		 */
		if (null != zkw.getUserid()) {
			if (!zkw.getUserid().endsWith("educ")) {
				log.error("只能是县市教育局登录");
				model.addAttribute("msg", "只能是县市教育局登录");
				return "loginJkz";
			}
		} else {
			log.error("登录用户不能为空");
			model.addAttribute("msg", "登录用户不能为空");
			return "loginJkz";
		}

		/**
		 * 根据县市招办代码查询高中学校信息
		 */
		Zkw zkwDb = new Zkw();
		zkwDb = zkwMapper.getOne(zkw.getUserid());
		if (null == zkwDb) {
			log.error("没有找到指定的县市招办");
			model.addAttribute("msg", "没有找到指定的县市招办");
			return "loginJkz";
		}

		/**
		 * 判断县市招办是否第一次登录（如果密码为空，或者和县市招办代码相同则是初次登录）
		 * 
		 * 如果是，跳转到修改密码界面，如果不是，则继续前进到操作选择页面
		 */
		String dbPassword = zkwDb.getPassword().trim();
		if (null == dbPassword || (dbPassword.equals(zkwDb.getUserid()) && dbPassword.equals(zkw.getPassword()))) {
			log.debug("县市招办初次登录 ，进入【密码修改页面】");
			model.addAttribute("zkw", zkwDb);
			session.setAttribute("zkw", zkwDb);
			return "city/changePasswdJkz";

		}

		// 验证是否找到对应的县市招办
		// 并且输入的密码是否和查找到的县市办密码是否一致
		if (null != zkwDb.getPassword() && zkwDb.getPassword().equals(zkw.getPassword())) {

			// 验证成功转到填报页面
			log.debug("验证【成功】");
			model.addAttribute("zkw", zkwDb);
			if (null == session) {
				session = wishFillingBiz.getSession();
			}
			session.setAttribute("zkw", zkwDb);

			// 转到艺体特色报名审核页面
			return "city/jkzselect";
		} else {
			// 验证失败继续回到登录页面
			// Model model = new Model();
			log.debug("验证【失败】");

			model.addAttribute("msg", "验证失败，招办代码或密码不正确");
			return "loginJkz";
		}

	}

	/**
	 * 跳转到修改密码页面
	 * 
	 * @param zkw
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/goChangePasswd", method = RequestMethod.POST)
	public String goChangePasswd(Model model) {
		HttpSession session = wishFillingBiz.getSession();
		if (null == session || null == session.getAttribute("zkw")) {
			session = null;
			log.error("县市招办未登录，请重新登录");
			return "redirect:/loginCity";
		}
		Zkw zkw = (Zkw) session.getAttribute("zkw");
		model.addAttribute("zkw", zkw);
		return "/city/changePasswdJkz";

	}

	@RequestMapping(value = "/doChangePasswd", method = RequestMethod.POST)
	public String changePwd(@ModelAttribute(value = "changePassword") ChangePassword changePassword,
			@SessionAttribute Zkw zkw, Model model) {

		HttpSession session = wishFillingBiz.getSession();
		if (null == session || null == session.getAttribute("zkw")) {
			session = null;
			log.error("县市招办未登录，请重新登录");
			return "redirect:/loginJkz";
		}
		// zkw = (Zkw) session.getAttribute("zkw");
		/**
		 * 判断传入的密码
		 */
		if (null == model || null == model.asMap() || null == model.asMap().get("changePassword")) {
			log.error("未取到前台返回的密码值 ");
			model.addAttribute("msg", "未取到前台返回的密码值");
			// model.addAttribute("student", student);
			return "/city/changePasswdJkz";
		}

		ChangePassword cp = (ChangePassword) model.asMap().get("changePassword");
		if (null == cp.getOldPassword()) {
			log.error("必须输入原来的密码值 ");
			model.addAttribute("msg", "必须输入原来的密码值");
			return "/city/changePasswdJkz";
		}
		if (null == cp.getNewPasswordOne() || null == cp.getNewPasswordTwo()) {
			log.error("必须输入新的码值 ");
			model.addAttribute("msg", "必须输入新的码值");
			// model.addAttribute("student", student);
			return "/city/changePasswdJkz";
		}

		String oldPassword = cp.getOldPassword();
		String newPasswordOne = cp.getNewPasswordOne();
		String newPasswordTwo = cp.getNewPasswordTwo();

		/**
		 * 如果输入的旧密码等于学生本来的旧密码才可以更换密码
		 */
		if (!oldPassword.isEmpty() && !zkw.getPassword().isEmpty()) {
			if (oldPassword.equals(zkw.getPassword())) {
				/**
				 * 两次输入密码要一致才有效
				 */
				if (newPasswordOne.equals(newPasswordTwo)) {
					zkw.setPassword(newPasswordOne);
				} else {
					log.error("两次密码不符，请重新核对 ");
					model.addAttribute("msg", "两次密码不符，请重新核对 ");
					model.addAttribute("zkw", zkw);
					return "/city/changePasswdJkz";
				}
			} else {
				log.error("原密码不符，请重新核对 ");
				model.addAttribute("msg", "原密码不符，请重新核对 ");
				model.addAttribute("zkw", zkw);
				return "/city/changePasswdJkz";
			}
		}
		/**
		 * 修改密码
		 */
		int result = cityService.changePassword(zkw);
		if (1 == result) {
			log.debug("密码修改成功");
		} else {
			log.warn("密码修改失败");
			model.addAttribute("zkw", zkw);
			return "city/changePasswdJkz";
		}
		/**
		 * 跳转到登录界面重新登录
		 */
		return "loginJkz";
	}

	/**
	 * 艺体审核
	 * 
	 */

	@RequestMapping("showArtSpecialtyCityInitYt")
	public String showArtSpecialtyCityInitYt(Model model, HttpServletResponse response) {

		/**
		 * 审核时间判断 6月22日08:00--6月23日23:59之间可用
		 */
		Date day = new Date();
		HttpSession session = wishFillingBiz.getSession();
		Zkw zkw = (Zkw) session.getAttribute("zkw");
		model.addAttribute("zkw", zkw);

		DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		try {
			response.setCharacterEncoding("UTF-8");

			Date now = df.parse(df.format(day)); // 当前时间
			Date startTime = df.parse(xsshkssj);
			Date endTime = df.parse(xsshjssj); // 截止时间
			if (now.before(endTime) && now.after(startTime)) {
				// 继续正常处理
				System.out.println("继续正常处理");

			} else {
				model.addAttribute("message", "不在审核时间范围内");
				response.getWriter().write("<script>alert('不在审核时间范围内');</script>");
				return "city/jkzselect";
			}
		} catch (Exception exception) {
			exception.printStackTrace();
			return "city/jkzselect";
		}

		if (null == session || null == session.getAttribute("zkw")) {
			session = null;
			log.error("未登录，请重新登录");
			/* return "redirect:/loginStatEnrol"; */
		}

		List<ArtSpecialtySignUp> students = cityService.getWishedStudentByXsdmArtSpecialtyCityYt(zkw.getXsdm());
		model.addAttribute("students", students);

		return "city/wishFillingCityYt";

	}

	@RequestMapping("showArtSpecialtyCityYt")
	@ResponseBody
	public List<ArtSpecialtySignUp> artSpecialtyYt(Model model) {
		HttpSession session = wishFillingBiz.getSession();
		if (null == session || null == session.getAttribute("zkw")) {
			session = null;
			log.error("县市招办未登录，请重新登录");
			// return "redirect:/loginCity";
		}
		Zkw zkw = (Zkw) session.getAttribute("zkw");
		model.addAttribute("zkw", zkw);

		List<ArtSpecialtySignUp> students = cityService.getWishedStudentByXsdmArtSpecialtyCityYt(zkw.getXsdm());
		model.addAttribute("students", students);
		return students;
		// return "city/wishFillingCityTs";
	}

	/**
	 * 特色审核
	 * 
	 */
	@RequestMapping("showArtSpecialtyCityInitTs")
	public String showArtSpecialtyCityInitTs(Model model, HttpServletResponse response) {

		/**
		 * 审核时间判断 6月22日08:00--6月23日23:59之间可用
		 */
		Date day = new Date();
		HttpSession session = wishFillingBiz.getSession();
		Zkw zkw = (Zkw) session.getAttribute("zkw");
		model.addAttribute("zkw", zkw);

		DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		try {
			response.setCharacterEncoding("UTF-8");

			Date now = df.parse(df.format(day)); // 当前时间
			Date startTime = df.parse(xsshkssj);
			Date endTime = df.parse(xsshjssj); // 截止时间
			if (now.before(endTime) && now.after(startTime)) {
				// 继续正常处理
				System.out.println("继续正常处理");

			} else {
				model.addAttribute("message", "不在审核时间范围内");
				response.getWriter().write("<script>alert('不在审核时间范围内');</script>");
				return "city/jkzselect";
			}
		} catch (Exception exception) {
			exception.printStackTrace();
			return "city/jkzselect";
		}

		if (null == session || null == session.getAttribute("zkw")) {
			session = null;
			log.error("未登录，请重新登录");
			/* return "redirect:/loginStatEnrol"; */
		}

		List<ArtSpecialtySignUp> students = cityService.getWishedStudentByXsdmArtSpecialtyCityTs(zkw.getXsdm());
		model.addAttribute("students", students);

		return "city/wishFillingCityTs";

	}

	@RequestMapping("showArtSpecialtyCityTs")
	@ResponseBody
	public List<ArtSpecialtySignUp> artSpecialtyTs(@ModelAttribute("bmh") String bmh, Model model) {
		HttpSession session = wishFillingBiz.getSession();
		if (null == session || null == session.getAttribute("zkw")) {
			session = null;
			log.error("县市招办未登录，请重新登录");
			// return "redirect:/loginCity";
		}
		Zkw zkw = (Zkw) session.getAttribute("zkw");
		model.addAttribute("zkw", zkw);

		List<ArtSpecialtySignUp> students = cityService.getWishedStudentByXsdmArtSpecialtyCityTs(zkw.getXsdm());
		model.addAttribute("students", students);
		return students;
		// return "city/wishFillingCityTs";
	}

	@RequestMapping("doSelectStudentWishByBmh")
	@ResponseBody
	public List<SignUpStudent> selectStudentWishByBmh(@ModelAttribute("bmh") String bmh,
			@ModelAttribute("sele") String sele, Model model) {
		ResponseVo vo = new ResponseVo();
		HttpSession session = wishFillingBiz.getSession();
		Zkw zkw = (Zkw) session.getAttribute("zkw");
		if (null == session || null == zkw) {
			session = null;
			log.error("县市招办未登录，请重新登录");
			vo.setCode("error");
			vo.setMessage("县市招办未登录，请重新登录");
			vo.setUrl("redirect:/loginCity");
			// return vo;
		}

		if (null == sele || sele.isEmpty()) {
			vo.setCode("stay");
			vo.setMessage("未收到查询条件学生填报类别");
			vo.setUrl("city/CountyEnrolStudent");
			// return vo;
		}

		if (null == bmh || bmh.isEmpty()) {
			vo.setCode("stay");
			vo.setMessage("未收到查询条件报名号");
			vo.setUrl("city/CountyEnrolStudent");
			// return vo;
		}
		List<SignUpStudent> students = new ArrayList<SignUpStudent>();
		/**
		 * 未填志愿
		 */
		if ("1".equals(sele)) {
			students = cityService.getWishedStudentByXsdmNotWished(zkw.getXsdm(), bmh);
		} else if ("0".equals(sele)) {
			/**
			 * 已填志愿
			 */
			students = cityService.getWishedStudentByXsdmWished(zkw.getXsdm(), bmh);
		}

		model.addAttribute("students", students);
		model.addAttribute("zkw", zkw);
		model.addAttribute("sele", sele);
		return students;
		// vo.setCode("ok");
		// vo.setMessage("查询完成");
		/*
		 * vo.setUrl("/city/CountyEnrolStudent");
		 * 
		 * return "/city/CountyEnrolStudent";
		 */
	}

	@RequestMapping(value = "doSelectArtSpecialtyByBmhYt", method = RequestMethod.POST)
	@ResponseBody
	public List<ArtSpecialtySignUp> selectArtSpecialtyByBmhYt(@ModelAttribute("bmh") String bmh,
			@ModelAttribute("sele") String sele, Model model) {
		ResponseVo vo = new ResponseVo();
		HttpSession session = wishFillingBiz.getSession();
		Zkw zkw = (Zkw) session.getAttribute("zkw");
		if (null == session || null == zkw) {
			session = null;
			log.error("县市招办未登录，请重新登录");
			vo.setCode("error");
			vo.setMessage("县市招办未登录，请重新登录");
			vo.setUrl("redirect:/loginCity");
			// return vo;
		}

		if (null == sele || sele.isEmpty()) {
			vo.setCode("stay");
			vo.setMessage("未收到查询条件学生填报类别");
			vo.setUrl("city/wishFillingCityYt");
			// return vo;
		}

		if (null == bmh || bmh.isEmpty()) {
			vo.setCode("stay");
			vo.setMessage("未收到查询条件报名号");
			vo.setUrl("city/wishFillingCityYt");
			// return vo;
		}
		List<ArtSpecialtySignUp> students = new ArrayList<ArtSpecialtySignUp>();

		students = cityService.getArtSpecialtySignUpByXsdmYt(zkw.getXsdm(), bmh);

		model.addAttribute("students", students);
		model.addAttribute("zkw", zkw);
		model.addAttribute("sele", sele);
		return students;
		// vo.setCode("ok");
		// vo.setMessage("查询完成");
		/*
		 * vo.setUrl("city/wishFillingCityYt");
		 * 
		 * return "city/wishFillingCityYt";
		 */
	}

	@RequestMapping(value = "doSelectArtSpecialtyByBmhTs", method = RequestMethod.POST)
	@ResponseBody
	public List<ArtSpecialtySignUp> selectArtSpecialtyByBmhTs(@ModelAttribute("bmh") String bmh,
			@ModelAttribute("sele") String sele, Model model) {
		ResponseVo vo = new ResponseVo();
		HttpSession session = wishFillingBiz.getSession();
		Zkw zkw = (Zkw) session.getAttribute("zkw");
		if (null == session || null == zkw) {
			session = null;
			log.error("县市招办未登录，请重新登录");
			vo.setCode("error");
			vo.setMessage("县市招办未登录，请重新登录");
			vo.setUrl("redirect:/loginCity");
			// return vo;
			/* return "redirect:/loginCity"; */
		}

		if (null == sele || sele.isEmpty()) {
			vo.setCode("stay");
			vo.setMessage("未收到查询条件学生填报类别");
			vo.setUrl("city/wishFillingCityTs");
			// return vo;
			/* return "city/wishFillingCityTs"; */
		}

		if (null == bmh || bmh.isEmpty()) {
			vo.setCode("stay");
			vo.setMessage("未收到查询条件报名号");
			vo.setUrl("city/wishFillingCityTs");
			// return vo;
		}
		List<ArtSpecialtySignUp> students = new ArrayList<ArtSpecialtySignUp>();

		students = cityService.getArtSpecialtySignUpByXsdmTs(zkw.getXsdm(), bmh);

		model.addAttribute("students", students);
		model.addAttribute("zkw", zkw);
		model.addAttribute("sele", sele);
		return students;
		// vo.setCode("ok");
		// vo.setMessage("查询完成");
		/*
		 * vo.setUrl("city/wishFillingCityTs");
		 * 
		 * return "city/wishFillingCityTs";
		 */
	}

	@RequestMapping("doSelectStudentWishByCondition")
	public String selectStudentWishByCondition(@ModelAttribute("sele") String sele, Model model) {
		HttpSession session = wishFillingBiz.getSession();
		ResponseVo vo = new ResponseVo();
		Zkw zkw = (Zkw) session.getAttribute("zkw");
		if (null == session || null == zkw) {
			session = null;
			log.error("县市招办未登录，请重新登录");
			vo.setCode("error");
			vo.setMessage("县市招办未登录，请重新登录");
			vo.setUrl("redirect:/loginCity");
			// return vo;
		}
		if (null == sele || sele.isEmpty()) {
			vo.setCode("stay");
			vo.setMessage("未收到查询条件学生填报类别");
			vo.setUrl("/city/CountyEnrolStudent");
			// return vo;

		}

		List<SignUpStudent> students = new ArrayList<SignUpStudent>();
		/**
		 * 未填志愿
		 */
		if ("1".equals(sele)) {
			students = cityService.getWishedStudentByXsdmNotWished(zkw.getXsdm(), null);
		} else if ("0".equals(sele)) {
			/**
			 * 已填志愿
			 */
			students = cityService.getWishedStudentByXsdmWished(zkw.getXsdm(), null);
		}

		model.addAttribute("students", students);
		model.addAttribute("zkw", zkw);
		model.addAttribute("sele", sele);

		// return vo;
		return "/city/CountyEnrolStudent";
	}

	@RequestMapping("doSelectStudentWishByBmhMiddle")
	public String selectStudentWishByBmhMiddle(@ModelAttribute("bmh") String bmh, @ModelAttribute("sele") String sele,
			Model model) {
		ResponseVo vo = new ResponseVo();
		HttpSession session = wishFillingBiz.getSession();
		Zkw zkw = (Zkw) session.getAttribute("zkw");
		if (null == session || null == zkw) {
			session = null;
			log.error("县市招办未登录，请重新登录");
			vo.setCode("error");
			vo.setMessage("县市招办未登录，请重新登录");
			vo.setUrl("redirect:/loginCity");
			// return vo;
		}

		if (null == sele || sele.isEmpty()) {
			vo.setCode("stay");
			vo.setMessage("未收到查询条件学生填报类别");
			vo.setUrl("city/CountyEnrolMidStudent");
			// return vo;
		}

		if (null == bmh || bmh.isEmpty()) {
			vo.setCode("stay");
			vo.setMessage("未收到查询条件报名号");
			vo.setUrl("city/CountyEnrolMidStudent");
			// return vo;
		}
		List<SignUpStudent> students = new ArrayList<SignUpStudent>();
		/**
		 * 未填志愿
		 */
		if ("1".equals(sele)) {
			students = cityService.getWishedStudentByXsdmNotWishedMiddle(zkw.getXsdm(), bmh);
		} else if ("0".equals(sele)) {
			/**
			 * 已填志愿
			 */
			students = cityService.getWishedStudentByXsdmWishedMiddle(zkw.getXsdm(), bmh);
		}

		model.addAttribute("students", students);
		model.addAttribute("zkw", zkw);
		model.addAttribute("sele", sele);

		// vo.setCode("ok");
		// vo.setMessage("查询完成");
		vo.setUrl("/city/CountyEnrolMidStudent");

		return "/city/CountyEnrolMidStudent";
	}

	@RequestMapping("doSelectStudentWishByConditionMiddle")
	public String selectStudentWishByConditionMiddle(@ModelAttribute("sele") String sele, Model model) {
		HttpSession session = wishFillingBiz.getSession();
		ResponseVo vo = new ResponseVo();
		Zkw zkw = (Zkw) session.getAttribute("zkw");
		if (null == session || null == zkw) {
			session = null;
			log.error("县市招办未登录，请重新登录");
			vo.setCode("error");
			vo.setMessage("县市招办未登录，请重新登录");
			vo.setUrl("redirect:/loginCity");
			// return vo;
		}
		if (null == sele || sele.isEmpty()) {
			vo.setCode("stay");
			vo.setMessage("未收到查询条件学生填报类别");
			vo.setUrl("/city/CountyEnrolMidStudent");
			// return vo;

		}

		List<SignUpStudent> students = new ArrayList<SignUpStudent>();
		/**
		 * 未填志愿
		 */
		if ("1".equals(sele)) {
			students = cityService.getWishedStudentByXsdmNotWishedMiddle(zkw.getXsdm(), null);
		} else if ("0".equals(sele)) {
			/**
			 * 已填志愿
			 */
			students = cityService.getWishedStudentByXsdmWishedMiddle(zkw.getXsdm(), null);
		}

		model.addAttribute("students", students);
		model.addAttribute("zkw", zkw);
		model.addAttribute("sele", sele);

		// return vo;
		return "/city/CountyEnrolMidStudent";
	}

	/**
	 * 单个提交审核状态（艺体特长）
	 * 
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "doSaveCheckResultYt", method = RequestMethod.POST)
	@ResponseBody
	public ResponseVo saveScoreYt(@ModelAttribute("row") ArtSpecialtySignUpCity artSpecialtySignUpCity, Model model) {
		ResponseVo vo = new ResponseVo();
		HttpSession session = wishFillingBiz.getSession();
		Zkw zkw = (Zkw) session.getAttribute("zkw");
		if (null == session || null == zkw) {
			session = null;
			log.error("县市招办未登录，请重新登录");
			// return "redirect:/loginHighSchool";
			vo.setCode("error");
			vo.setMessage("县市招办未登录，请重新登录");
			vo.setUrl("redirect:/loginCity");
			return vo;
		}
		// String row = (String) model.asMap().get("row");
		/**
		 * 后台数据库保存审核状态
		 */
		// String bmh=(String) model.asMap().get("bmh");
		ArtSpecialtySignUp artSpecialtySignUp = new ArtSpecialtySignUp();
		artSpecialtySignUp.setBmh(artSpecialtySignUpCity.getBmh());
		artSpecialtySignUp.setXsshzt(artSpecialtySignUpCity.getXsshzt());
		int result = cityService.updateArtSpecialtyScoreYt(artSpecialtySignUp);
		if (result != 1) {
			log.error("提交审核状态失败");
			// return "redirect:/loginHighSchool";
			vo.setCode("error");
			vo.setMessage("提交审核状态失败");
			vo.setUrl("city/wishFillingCityYt");
			// return vo;
		} else {
			vo.setCode("ok");
			vo.setMessage("提交成绩成功");
			vo.setUrl("city/wishFillingCityYt");
		}
		// return "highschool/wishFillingHighSchoolTs";
		return vo;
	}

	/**
	 * 单个提交审核状态（特色项目）
	 * 
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "doSaveCheckResultTs", method = RequestMethod.POST)
	@ResponseBody
	public ResponseVo saveScoreTs(@ModelAttribute("row") ArtSpecialtySignUpCity artSpecialtySignUpCity, Model model) {
		ResponseVo vo = new ResponseVo();
		HttpSession session = wishFillingBiz.getSession();
		Zkw zkw = (Zkw) session.getAttribute("zkw");
		if (null == session || null == zkw) {
			session = null;
			log.error("县市招办未登录，请重新登录");
			// return "redirect:/loginHighSchool";
			vo.setCode("error");
			vo.setMessage("县市招办未登录，请重新登录");
			vo.setUrl("redirect:/loginCity");
			return vo;
		}
		// String row = (String) model.asMap().get("row");
		/**
		 * 后台数据库保存审核状态
		 */
		// String bmh=(String) model.asMap().get("bmh");
		ArtSpecialtySignUp artSpecialtySignUp = new ArtSpecialtySignUp();
		artSpecialtySignUp.setBmh(artSpecialtySignUpCity.getBmh());
		artSpecialtySignUp.setXsshzt(artSpecialtySignUpCity.getXsshzt());
		int result = cityService.updateArtSpecialtyScoreTs(artSpecialtySignUp);
		if (result != 1) {
			log.error("提交审核状态失败");
			// return "redirect:/loginHighSchool";
			vo.setCode("error");
			vo.setMessage("提交审核状态失败");
			vo.setUrl("city/wishFillingCityTs");
			// return vo;
		} else {
			vo.setCode("ok");
			vo.setMessage("提交成绩成功");
			vo.setUrl("city/wishFillingCityTs");
		}
		// return "highschool/wishFillingHighSchoolTs";
		return vo;
	}

	/**
	 * 批量审核通过（特色项目）
	 * 
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "doExamineTs", method = RequestMethod.POST)
	@ResponseBody
	public ResponseVo examineTs(Model model, @RequestParam("bmh") String bmh) {
		ResponseVo vo = new ResponseVo();
		HttpSession session = wishFillingBiz.getSession();
		Zkw zkw = (Zkw) session.getAttribute("zkw");
		if (null == session || null == zkw) {
			session = null;
			log.error("县市招办未登录，请重新登录");
			// return "redirect:/loginHighSchool";
			vo.setCode("error");
			vo.setMessage("县市招办未登录，请重新登录");
			vo.setUrl("redirect:/loginCity");
			return vo;
		}
		/**
		 * 后台数据库保存审核状态（审核通过）
		 */
		int result = cityService.updateArtSpecialtyExamineByBmhTs(bmh);
		if (result != 1) {
			log.error("审核状态更新失败");
			// return "redirect:/loginHighSchool";
			vo.setCode("error");
			vo.setMessage("审核状态更新失败");
			vo.setUrl("city/wishFillingCityTs");
			return vo;
		}
		vo.setCode("ok");
		vo.setMessage("审核通过更新成功");
		vo.setUrl("city/wishFillingCityTs");
		// return "highschool/wishFillingHighSchoolTs";
		return vo;
	}

	/**
	 * 批量审核通过（艺体特长）
	 * 
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "doExamineYt", method = RequestMethod.POST)
	@ResponseBody
	public ResponseVo examineYt(Model model, @RequestParam("bmh") String bmh) {
		ResponseVo vo = new ResponseVo();
		HttpSession session = wishFillingBiz.getSession();
		Zkw zkw = (Zkw) session.getAttribute("zkw");
		if (null == session || null == zkw) {
			session = null;
			log.error("县市招办未登录，请重新登录");
			// return "redirect:/loginHighSchool";
			vo.setCode("error");
			vo.setMessage("县市招办未登录，请重新登录");
			vo.setUrl("redirect:/loginCity");
			return vo;
		}
		/**
		 * 后台数据库保存审核状态（审核通过）
		 */
		int result = cityService.updateArtSpecialtyExamineByBmhYt(bmh);
		if (result != 1) {
			log.error("审核状态更新失败");
			// return "redirect:/loginHighSchool";
			vo.setCode("error");
			vo.setMessage("审核状态更新失败");
			vo.setUrl("city/wishFillingCityYt");
			return vo;
		}
		vo.setCode("ok");
		vo.setMessage("审核通过更新成功");
		vo.setUrl("city/wishFillingCityYt");
		// return "highschool/wishFillingHighSchoolTs";
		return vo;
	}

	/**
	 * 批量审核未通过（艺体）
	 * 
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "doCancelExamineYt", method = RequestMethod.POST)
	@ResponseBody
	public ResponseVo cancelExamineYt(Model model, @RequestParam("bmh") String bmh) {
		ResponseVo vo = new ResponseVo();
		HttpSession session = wishFillingBiz.getSession();
		Zkw zkw = (Zkw) session.getAttribute("zkw");
		if (null == session || null == zkw) {
			session = null;
			log.error("县市招办未登录，请重新登录");
			// return "redirect:/loginHighSchool";
			vo.setCode("error");
			vo.setMessage("县市招办未登录，请重新登录");
			vo.setUrl("redirect:/loginCity");
			return vo;
		}
		/**
		 * 后台数据库保存审核状态（审核未通过）
		 */
		int result = cityService.updateArtSpecialtyCancelExamineByBmhYt(bmh);
		if (result != 1) {
			log.error("审核状态更新失败");
			// return "redirect:/loginHighSchool";
			vo.setCode("error");
			vo.setMessage("审核状态更新失败");
			vo.setUrl("city/wishFillingCityYt");
			return vo;
		}
		vo.setCode("ok");
		vo.setMessage("审核未通过更新成功");
		vo.setUrl("city/wishFillingCityYt");
		// return "highschool/wishFillingHighSchoolTs";
		return vo;
	}

	/**
	 * 批量审核未通过（特色）
	 * 
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "doCancelExamineTs", method = RequestMethod.POST)
	@ResponseBody
	public ResponseVo cancelExamineTs(Model model, @RequestParam("bmh") String bmh) {
		ResponseVo vo = new ResponseVo();
		HttpSession session = wishFillingBiz.getSession();
		Zkw zkw = (Zkw) session.getAttribute("zkw");
		if (null == session || null == zkw) {
			session = null;
			log.error("县市招办未登录，请重新登录");
			// return "redirect:/loginHighSchool";
			vo.setCode("error");
			vo.setMessage("县市招办未登录，请重新登录");
			vo.setUrl("redirect:/loginCity");
			return vo;
		}
		/**
		 * 后台数据库保存审核状态（审核未通过）
		 */
		int result = cityService.updateArtSpecialtyCancelExamineByBmhTs(bmh);
		if (result != 1) {
			log.error("审核状态更新失败");
			// return "redirect:/loginHighSchool";
			vo.setCode("error");
			vo.setMessage("审核状态更新失败");
			vo.setUrl("city/wishFillingCityTs");
			return vo;
		}
		vo.setCode("ok");
		vo.setMessage("审核未通过更新成功");
		vo.setUrl("city/wishFillingCityTs");
		// return "highschool/wishFillingHighSchoolTs";
		return vo;
	}

	@RequestMapping("forgetPwd")
	public String forgetPwd() {
		return "city/CountyEnrolStudent";
	}

	@RequestMapping("logout")
	public String logou() {
		HttpSession session = wishFillingBiz.getSession();
		if (null != session) {
			session.removeAttribute("zkw");
		}

		return "loginJkz";
	}

}
